package cn.com.geoway.booksystem.dao;

import cn.com.geoway.booksystem.entity.Book;
import cn.com.geoway.booksystem.entity.Borrow;
import org.hibernate.annotations.OnDelete;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;

public interface BookBorrowDao extends JpaRepository<Borrow,Integer>, JpaSpecificationExecutor<Borrow> {

    @Query(value="select * from t_book_borrow where id = ?1",nativeQuery = true)
    public Borrow findId(Integer id);

    @Transactional
    @Modifying
    @Query(value = "delete from t_book_borrow where book_id =?1",nativeQuery = true)
    public void deleteByBookId(Integer id);

}
